package com.xiaoge.demo.dao;

import com.xiaoge.demo.dto.UserDto;
import com.xiaoge.demo.pojo.User;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserDao extends JpaRepository<User, String> {
    @Query("select new com.xiaoge.demo.dto.UserDto(u.id, u.name, u.pwd, u.account, u.phone, u.token) from User u where u.is_delete = '0'")
    List<UserDto> findPartMsgList(Pageable pageable);

    @Query("select new com.xiaoge.demo.dto.UserDto(u.id, u.name, u.pwd, u.account, u.phone, u.token) from User u where u.is_delete = '0' and u.id =:userId")
    UserDto getOneById(@Param("userId") String userId);
}
